package com.kye.express.business.jd.address_select;

import com.kye.express.contract.base.BasePresenter;
import com.kye.express.contract.base.view.IView;
import com.kye.model.UserSession;
import com.kye.model.bean.user.User;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;

/**
 * @author : Joe
 * @version : 1.0
 * @editor : Joe
 * @created : 31/01/2018
 * @updated : 31/01/2018
 * @description : <Description>
 * @update_reason : <UpdateReason>
 */

public class AddressSelectConstract {

    interface AddressView extends IView {

        void onUser(User user);
    }

    public class AddressPresenter extends BasePresenter<AddressSelectConstract.AddressView> {

        @Override
        public void bind(AddressView view) {
            super.bind(view);
            UserSession.getInstance()
                    .getUserForRx()
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new Consumer<User>() {
                        @Override
                        public void accept(User user) throws Exception {
                            getView().onUser(user);
                        }
                    });
        }
    }
}
